# coding:utf-8

from lib.base_ios import Base
from page.ios import train_list_page, train_calendar_page, train_fare_adjustment_page, train_index_page

__author__ = 'weixin.yuan'


class TrainList(Base):
    """火车车次列表"""
    def __init__(self, method_name):
        Base.__init__(self, method_name)

        """
        本页元素
        """
        self.bupiao_btn = train_list_page.elements['补票按钮']
        self.train_btn = train_list_page.elements['火车按钮']
        self.zhongzhuan_btn = train_list_page.elements['中转按钮']
        self.plane_btn = train_list_page.elements['飞机按钮']
        self.calendar_btn = train_list_page.elements['日历按钮']
        self.travel_time_btn = train_list_page.elements['旅行耗时按钮']
        self.begin_time_btn = train_list_page.elements['出发时间按钮']
        self.high_speed_rail_btn = train_list_page.elements['高铁动车按钮']
        self.zuhe_filter_btn = train_list_page.elements['综合筛选按钮']
        self.zonghe_filter = train_list_page.elements['zonghe_filter']
        self.commit = train_list_page.elements['确定按钮']

        """
        外部页面元素
        """
        self.question_mark = train_fare_adjustment_page.elements['问号按钮']
        self.search = train_index_page.elements['搜索按钮']
        self.from_time = train_calendar_page.elements['选择日期title']

    def test_train_list(self):
        """火车车次查询列表页check"""
        self.open_schema_ios('6002')
        self.click(self.search)

        self.click(self.bupiao_btn)
        self.check(self.question_mark)
        self.back()

        self.click(self.calendar_btn)
        self.check(self.from_time)
        self.back()

        self.click_exists(self.zhongzhuan_btn)
        self.click_exists(self.train_btn)

        self.click(self.begin_time_btn)
        self.click(self.travel_time_btn)
        self.click(self.high_speed_rail_btn)
        self.click(self.zuhe_filter_btn)

        for btn in self.zonghe_filter:
            self.click_exists(self.zonghe_filter[btn])

        self.click_exists(self.commit)

        self.click_exists(self.plane_btn)

